#ifndef	__TURBINE_SIMULATOR__
#define __TURBINE_SIMULATOR__

#include <llib.h>
#include <vector>
#include <boost/timer.hpp>

using namespace std;
using namespace llib;
using namespace llib::geom;

#ifndef TRIANGLE3F
#define TRIANGLE3F

template <typename T>
class Vector3 {
public:
    union {
        struct { T x, y, z; };
        struct { T cell[3]; };
    };
};

typedef Vec3f                       Vector3f;
typedef Vec3i                       Vector3i;
typedef Vec2f                       Vector2f;

typedef Vector3<Vector2f>			Triangle3f_2D;
typedef Vector3<Vector3f>			Triangle3f;
typedef Vector3<Vector3i>			Triangle3i;
typedef Vector3< Vector3<Boolean> >		Triangle3b;
#endif

class TurbineModel {
private:
    Vector3f            m_Center;
    Float               m_Radius;
    Int32               m_FanNum;
    Float               m_AngularVelocity;
    Float               m_StartAngle;
public:
    vector<Triangle3f>  TriList;
    vector<Boolean>     TriCollision;
    TurbineModel(Vector3f center, Float radius, Int32 fanNum, Float angularVelocity, Float startAngle);
    void update(Float time);
};

class TurbineSimulator : public Simulator {
public:
    TurbineSimulator();
    Boolean Initialize();
    Boolean Render();
    Boolean OnSpecialKeyDown(Uint8 key, Int32 x, Int32 y, Uint8 modifiers);
    Boolean OnKeyDown(Uint8 key, Int32 x, Int32 y, Uint8 modifiers);
private:
    /* view point stuff */
    Float       m_viewPointAngle;
    const Float m_viewPointAngleDelta;
    Float       m_viewPointDistance;
    const Float m_viewPointDistanceDelta;
    const Float m_viewPointDistanceMax;
    const Float m_viewPointDistanceMin;
    const Float m_viewPointHeight;

    /* animation stuff */
    const Float m_timeDelta;
    Float       m_lastTime;
    Int32       m_stepId;
    boost::timer m_timer;
    Color       m_colorCollisionFree;
    Color       m_colorCollision;
    Boolean     m_pause;
    Float       m_pausedTime;

    /* model stuff */
    TurbineModel    m_leftTurbine;
    TurbineModel    m_rightTurbine;

};






#endif	// __TURBINE_SIMULATOR__